#!/usr/bin/env bash
# 启用 POSIX 模式并设置严格的错误处理机制
set -o posix errexit -o pipefail

mkdir -p /home/kubernetes/cilium
cd /home/kubernetes/cilium || exit

rm -rf cilium-*.tar.gz

PROXY="https://www.ghproxy.cn/"
# https://raw.githubusercontent.com/cilium/cilium-cli/main/stable.txt
CILIUM_CLI_VERSION=v0.16.22
CLI_ARCH=""
# 使用uname -m获取架构信息
machine=$(uname -m)
# 判断架构信息并设置变量的值
if [ "$machine" = "aarch64" ]; then
    CLI_ARCH="arm64"
elif [ "$machine" = "x86_64" ]; then
    CLI_ARCH="amd64"
else
    echo "请手动定义你的发行版的架构"
fi
echo $CLI_ARCH
echo $CILIUM_CLI_VERSION
echo $PROXY
wget -t 2 -T 240 -N -S "${PROXY}"https://github.com/cilium/cilium-cli/releases/download/"${CILIUM_CLI_VERSION}"/cilium-linux-${CLI_ARCH}.tar.gz
sha256sum --check cilium-linux-${CLI_ARCH}.tar.gz.sha256sum
sudo tar xzvfC cilium-linux-${CLI_ARCH}.tar.gz /usr/local/bin
